﻿using System.Collections.Generic;
using DeviceManagement;

namespace WindowsFormsSample
{
	public enum DeviceComparisonFlag
	{
		ClassGuid = 1
	}

	public class DeviceEqualityComparer : IEqualityComparer<DeviceInfo>
	{
		readonly DeviceComparisonFlag _flag;

		public DeviceEqualityComparer(DeviceComparisonFlag flag) { this._flag = flag; }


		#region IEqualityComparer<DeviceInfo> Members

		public bool Equals(DeviceInfo x, DeviceInfo y)
		{
			if (this._flag == DeviceComparisonFlag.ClassGuid)
				return x.ClassGuid.Equals(y.ClassGuid);

			return x.Equals(y);
		}

		public int GetHashCode(DeviceInfo obj)
		{
			if (this._flag == DeviceComparisonFlag.ClassGuid)
				return obj.ClassGuid.GetHashCode();

			return obj.GetHashCode();
		}

		#endregion
	}
}
